本日新增:
package Project1.Allcode;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class HistorySystem {
public void searchHistory(String userName, Scanner input) {
int count = 0;
int totalCorrect = 0;
int totalWrong = 0;
double totalAccuracy = 0;
double highestAccuracy = 0;
try {
Scanner file = new Scanner(new File("history.txt"));
while (file.hasNextLine()) {
String line = file.nextLine();
String[] data = line.split(", ");
if (data.length != 5) {
continue;
}
if (data[0].trim().equals(userName.trim())) {
count++;
totalCorrect += Integer.parseInt(data[2]);
totalWrong += Integer.parseInt(data[3]);
double accuracy = Double.parseDouble(data[4]);
totalAccuracy += accuracy;
if (count == 1 || accuracy > highestAccuracy) {
highestAccuracy = accuracy;
}
System.out.println(" 測驗時間:" + data[1]);
System.out.println(" 答對題數:" + data[2]);
System.out.println(" 答錯題數:" + data[3]);
System.out.println(" 正確率:" + data[4] + "%");
System.out.println();
}
}
file.close();
if (count == 0) {
System.out.println(" 查無此使用者的歷史成績 ");
} else {
System.out.println(" 歷史成績統計 ");
System.out.println(" 使用者姓名:" + userName);
System.out.println(" 測驗次數:" + count);
System.out.printf(" 平均正確率:%.2f%%\n",
totalAccuracy / count);
System.out.println(" 最高正確率:" + highestAccuracy + "%");
System.out.println(" 累計答對題數:" + totalCorrect);
System.out.println(" 累計答錯題數:" + totalWrong);
}
} catch (IOException e) {
System.out.println(" 無法讀取歷史成績檔案 ");
}
System.out.println();
}
}
整體結語:
透過這次 30 天自主學習計畫,我慢慢接觸了更深的內容,感覺碰到了瓶頸、一直需要靠 AI 協助,覺得自己很不熟練,好幾次中途想要放棄,不過我後來想想,好像也是正常的,不能指望靠這一個月就變成大師![]()
再後來,寫著寫著就慢慢習慣了,有的時候其他事忙到快沒時間了,還是會上來打一點字、學一點技術,逼自己適應這個節奏,然後大概在 20 天左右的時候,開始發想想做這個成果,但是一看到進度,發現好像來不及......所以後面的進度很明顯在趕火車,學的也沒有很透徹,接下來應該會花一點時間嘗試理解他們![]()
雖然這段時間有點痛苦,但我認為都是一個過程,跨過這個坎,才有可能有另一片天!也就是說,未來如果我想往這個方向走,還有很長一段路要去摸索、去學習(畢竟不是本科系),持續精進自己,才是最重要的!